# -*- coding: UTF-8 -*-

from ..models import BaseModel


class ResUsers(BaseModel):
    _model = 'res.users'

    @classmethod
    def test(cls):
        # 示例代码. 如何扩展函数
        return cls.search([('id', '>', 0)])


class ResPartnerCustomerForDemo(BaseModel):
    _model = 'res.partner'

    _domain_default = [['customer_rank', '>', 0]]
    _fields = ['name', 'customer_rank']

    @classmethod
    def search_read(cls, domain=None, fields=None, offset=0, limit=None, order=None):
        if not domain:
            domain = []
        domain2 = domain + cls._domain_default
        fields = cls._fields

        return super().search_read(domain=domain2, fields=fields, offset=offset, limit=limit, order=order)
